<template>
  <a-card :bordered="false">
  <a-tabs @change="changeTab" v-model="activeKey">
    <a-tab-pane :tab="$t('m.bpm.analyze.processDefAnalyze')" key="1">
      <ProcessDefAnalyze></ProcessDefAnalyze>
    </a-tab-pane>
    <a-tab-pane :tab="$t('m.bpm.analyze.taskAnalyze')" key="2">
      <TaskAnalyze></TaskAnalyze>
    </a-tab-pane>
    <a-tab-pane :tab="$t('m.bpm.analyze.taskDueAnalyze')" key="3">
      <TaskDueAnalyze></TaskDueAnalyze>
    </a-tab-pane>
    <a-tab-pane :tab="$t('m.bpm.analyze.processInstanceAnalyze')" key="4">
      <ProcessInstanceAnalyze></ProcessInstanceAnalyze>
    </a-tab-pane>
    <a-button slot="tabBarExtraContent" type="primary" @click="synAnalyzeData">
      {{$t('m.bpm.analyze.synAnalyzeData')}}
    </a-button>
  </a-tabs>
  </a-card>
</template>

<script>

  import ProcessDefAnalyze from './ProcessDefAnalyze'
  import TaskAnalyze from './TaskAnalyze'
  import TaskDueAnalyze from './TaskDueAnalyze'
  import ProcessInstanceAnalyze from './ProcessInstanceAnalyze'
  import YchConstant from "@/api/YchConstant";
  import {getAction} from '@/api/manage'

  export default {
    name: 'AnalyzeIndex',
    components: {
      ProcessDefAnalyze,
      TaskAnalyze,
      TaskDueAnalyze,
      ProcessInstanceAnalyze
    },
    props: {

    },
    data () {
      return {
        activeKey: '1',
        spinning: 0,//遮罩
        url:{
          synAnalyzeData:YchConstant.PREFIX_BPM + '/analyze/processAnalyzeRest/synAnalyzeData/v1',
        },
      }
    },
    methods: {
      changeTab (activeKey) {
        this.activeKey = activeKey
      },
      synAnalyzeData(){
        let that = this
        this.$confirm({
          content: '流程数据默认定时自动同步，您也可以手动触发同步数据，确定要手动同步数据吗？',
          onOk() {
            that.doSynData()
          },
          onCancel() {
          }
        })


      },
      doSynData(){
        this.spinning++;
        getAction(this.url.synAnalyzeData, {}).then((res) => {
          if (res.success) {
            this.messageUtil.success('流程分析数据同步成功')
          } else {
            this.messageUtil.warning(res.message);
          }
        }).finally(() => {
          this.spinning--;
        });
      },
    },
  }
</script>
<style lang="less" scoped>
  /deep/ .ant-card-body {
    padding: 10px 24px 5px 24px !important;
  }
</style>
